package com.ly.heart.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ly.common.core.domain.AjaxResult;
import com.ly.common.exception.CustomException;
import com.ly.common.utils.DateUtils;
import com.ly.common.utils.erp.SnowflakeIdWorker;
import com.ly.heart.mapper.KingInvoicePayableReceivableOtherDetailMapper;
import com.ly.heart.service.IKingInvoicePayableReceivableOtherDetailService;
import org.springframework.stereotype.Service;
import com.ly.heart.domain.KingInvoicePayableReceivableOtherDetailEntity;

import javax.annotation.Resource;

/**
 * 金蝶-财务-其他应付单明细/其他应收单明细Service业务层处理
 * @author wutao
 * @date 2024-07-19
 */
@Service
public class KingInvoicePayableReceivableOtherDetailServiceImpl extends ServiceImpl<KingInvoicePayableReceivableOtherDetailMapper, KingInvoicePayableReceivableOtherDetailEntity> implements IKingInvoicePayableReceivableOtherDetailService {

    @Resource
    private KingInvoicePayableReceivableOtherDetailMapper kingInvoicePayableReceivableOtherDetailEntityMapper;

    /**
     * 查询金蝶-财务-其他应付单明细/其他应收单明细列表
     * @param kingInvoicePayableReceivableOtherDetailEntity 金蝶-财务-其他应付单明细/其他应收单明细
     * @return 金蝶-财务-其他应付单明细/其他应收单明细
     */
    @Override
    public List<KingInvoicePayableReceivableOtherDetailEntity> selectKingInvoicePayableReceivableOtherDetailEntityList (KingInvoicePayableReceivableOtherDetailEntity kingInvoicePayableReceivableOtherDetailEntity) {
        return kingInvoicePayableReceivableOtherDetailEntityMapper.selectKingInvoicePayableReceivableOtherDetailEntityList ( kingInvoicePayableReceivableOtherDetailEntity );
    }

    /**
     * 新增金蝶-财务-其他应付单明细/其他应收单明细
     * @param kingInvoicePayableReceivableOtherDetailEntity 金蝶-财务-其他应付单明细/其他应收单明细
     * @return 结果
     */
    @Override
    public AjaxResult insertKingInvoicePayableReceivableOtherDetailEntity (KingInvoicePayableReceivableOtherDetailEntity kingInvoicePayableReceivableOtherDetailEntity) {
        kingInvoicePayableReceivableOtherDetailEntity.setId ( SnowflakeIdWorker.getInstance ().nextStringId () );
        kingInvoicePayableReceivableOtherDetailEntity.setCreateBy ( SnowflakeIdWorker.getInstance ().nextStringId () );
        kingInvoicePayableReceivableOtherDetailEntity.setCreateTime ( DateUtils.getNowDate () );
        boolean save = this.save ( kingInvoicePayableReceivableOtherDetailEntity );
        if ( ! save ) {
            throw new CustomException ( "更新其他应" + ( kingInvoicePayableReceivableOtherDetailEntity.getType () == 1 ? "付" : "收" ) + "单明细失败！" );
        }
        return AjaxResult.success ( "更新其他应" + ( kingInvoicePayableReceivableOtherDetailEntity.getType () == 1 ? "付" : "收" ) + "单明细失败！" );
    }

}
